package online.shenme;

import java.util.Random;
import java.util.Scanner;

//求min~max初始值与之间的奇数之和
public class round {
    public static void main(String[] args) {
        int min, max, sum, x;
        Scanner input = new Scanner(System.in);

        for (; ; ) {

            System.out.println("请输入最小值");
            min = input.nextInt();
            System.out.println("请输入最大值");
            max = input.nextInt();

            if (max > min) {
                break;
            } else {
                System.out.println("输入错误，请重新输入：");
            }
        }

        sum = min;
        sum += max;
        x = min;
        for (int i = min; i <= max; i++) {
            // 判断当前元素是否是最后一个，如果是的话，还是个奇数，结束循环
            if ((i == max || i == min) && i % 2 == 1) {
                continue;
            }
            if (i % 2 == 1) {
                sum += i;
            }
        }


        System.out.println("总和：" + sum);
    }
}

